<template>
  <div class="front-container">
    <div class="header">
      <div class="header-left">
        <div class="logo">
          <h1 @click="toHome()">盲盒商城</h1>
        </div>

        <div class="nav">
          <ul>
            <li>关注</li>
          </ul>
        </div>
      </div>

      <div class="header-middle">
        <el-input size="small" placeholder="请输入关键字" v-model="condition.keyword" class="input-with-select">
          <el-button slot="append" icon="el-icon-search" @click="search()"></el-button>
        </el-input>
      </div>

      <div class="header-right">
        <div class="nav">
          <ul>
            <li @click="toCart">购物车</li>
            <li @click="toOrder">我的订单</li>

          </ul>
        </div>

        <el-dropdown size="medium" @command="handleCommand">
          <div class="el-dropdown-link">
            <el-avatar
              src="https://cn.bing.com/images/search?q=%E5%A4%B4%E5%83%8F&FORM=IQFRBA&id=6E8860BEADD760736BEA422E3C9BF57317AA4F3E" />
          </div>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item icon="el-icon-user-solid" command="profile">
                个人中心
              </el-dropdown-item>

              <el-dropdown-item icon="el-icon-s-platform" v-if="isAdmin" command="back">
                后台系统
              </el-dropdown-item>
              <el-dropdown-item icon="el-icon-error" command="exit">
                退出登录
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>

      </div>
    </div>

    <div class="main">
      <router-view />
    </div>

    <div class="footer">
      <div class="footer-top">
        <div class="slogan">
          <span>你的幸运就在这一盒</span>
          <span>每一盒都是心跳时刻</span>
        </div>
        <el-divider></el-divider>
      </div>
      <div class="footer-bottom">
        <div class="school">
          <img src="@/assets/logo1.jpg" />
        </div>
        <div class="shop">
          <div class="logo">盲盒商城</div>
          <div class="desc">盲盒商城毕设项目</div>
        </div>
        <div class="ul-box">
          <ul>
            <li>关于我们</li>
            <li>帮助文档</li>
            <li>意见反馈</li>
            <li>举报中心</li>
          </ul>
          <ul>
            <li>
              <i class="el-icon-user-solid"></i>
              xyz
            </li>
            <li>
              <i class="el-icon-location"></i>
              xxx班级
            </li>
            <li>
              <i class="el-icon-phone"></i>
              18933334444
            </li>
            <li>
              <i class="el-icon-s-comment"></i>
              xxxxxyyyyy@qq.com
            </li>
          </ul>
        </div>
        <div class="qr-code">
          <div class="vx">
            <el-avatar shape="square" :size="110"
              src="https://ts1.cn.mm.bing.net/th/id/R-C.bcd18b2eff79aa76c210cb1b4fa9e718?rik=TWBJEYvTNbweXA&riu=http%3a%2f%2fpic.616pic.com%2fys_bnew_img%2f00%2f10%2f41%2fe0SAYdMOs1.jpg&ehk=o1kc%2fcW7P17uacN%2fn%2fqoQKqoYYaY3TmPdLFC0lXqfkM%3d&risl=&pid=ImgRaw&r=0"></el-avatar>
            <div class="title" style="width: 80px">开发者微信</div>
          </div>
          <div class="qq">
            <el-avatar shape="square" :size="110"
              src="https://ts1.cn.mm.bing.net/th/id/R-C.bcd18b2eff79aa76c210cb1b4fa9e718?rik=TWBJEYvTNbweXA&riu=http%3a%2f%2fpic.616pic.com%2fys_bnew_img%2f00%2f10%2f41%2fe0SAYdMOs1.jpg&ehk=o1kc%2fcW7P17uacN%2fn%2fqoQKqoYYaY3TmPdLFC0lXqfkM%3d&risl=&pid=ImgRaw&r=0"></el-avatar>
            <div class="title" style="width: 75px">开发者QQ</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import storage from '@/utils/storage'
export default {
  name: '',
  data() {
    return {
      condition: {
        keyword: '',
      },
      isAdmin: false,
      loginUser: {},
      userIds: [],
      postIds: [],
    }
  },
  created() {
    this.getLoginUser()
  },

  methods: {
    toCart() {
      this.$router.push('/front/cart')
    },
    toOrder() {
      this.$router.push('/front/order')
    },
    readOne() {
      this.postIds = [sessionStorage.getItem('recommendPostId')]
    },
    search() {
      console.log(this.condition)
      this.$api.product.search(this.condition).then((res) => {
        if (res.code === 200) {
        }
      })
    },
    getLoginUser() {
      this.loginUser = storage.getLoginUser()
      this.isAdmin = this.loginUser.role == 1
    },
    toHome() {
      this.$router.push('/front/home')
    },
    handleCommand(command) {
      if (command === 'profile') {
        this.$router.push('/front/profile')

      } else if (command === 'back') {
        setTimeout(() => {
          this.$router.push('/back/users')
        }, 200)
      } else if (command === 'exit') {
        sessionStorage.clear()
        setTimeout(() => {
          this.$router.push('/')
        }, 200)

        this.$message({
          message: '退出成功',
          type: 'success',
        })
      }
    },


  },
}
</script>

<style lang="scss" scoped>
.front-container {
  $theme-color: rgb(64, 158, 255);
  $header-with: calc(100vw - 17px);
  display: flex;
  height: auto;
  flex-direction: column;

  .header {
    // 固定不动
    width: $header-with;
    position: fixed;
    z-index: 10;

    display: flex;
    flex-direction: row;
    height: 50px;
    background-color: white;
    border-bottom: 1px solid rgb(240, 240, 240);
    box-shadow: 0 0 5px 1px rgb(240, 240, 240);

    .nav {
      ul {
        margin: 0;
        display: flex;

        li {
          padding: 0 10px;
          list-style-type: none;
          line-height: 50px;
          text-align: center;
          cursor: pointer;

          &:hover {
            background-color: rgb(240, 240, 245);
          }
        }
      }
    }

    &-left {
      display: flex;
      width: 30%;
      min-width: 312px;

      .logo {
        margin: 0 40px;

        h1 {
          cursor: pointer;
          margin: 0;
          line-height: 50px;
          color: $theme-color;
        }
      }
    }

    &-middle {
      display: flex;
      flex: 1;
      align-items: center;
      justify-content: center;
      min-width: 250px;

      .el-input {
        width: 70%;

        :deep(.el-input__inner) {
          line-height: 22px;
          border-radius: 16px 0 0 16px;
        }

        :deep(.el-input-group__append) {
          border-color: $theme-color;
          background-color: $theme-color;
          border-radius: 0 16px 16px 0;
          color: white;
        }
      }
    }

    &-right {
      width: 30%;
      min-width: 300px;
      align-items: center;
      display: flex;
      justify-content: flex-end;

      .nav {
        min-width: 160px;

        ul {
          justify-content: end;

          li {
            .el-badge {
              line-height: 20px;
              height: 24px;
            }
          }
        }
      }

      .el-dropdown {
        margin-left: 28px;
      }

      .publish {
        margin: auto 30px;

        .el-button {
          padding: 5px 13px;
          font-size: 16px;
          display: flex;
          align-items: center;

          :deep(i) {
            font-size: 20px;
          }
        }
      }
    }
  }

  .main {
    width: 80%;
    min-width: 878px;
    height: 100%;
    margin-top: 50px;
    align-self: center;
  }

  .footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: rgb(157, 157, 157);
    border-top: 1px solid rgb(240, 240, 240);
    box-shadow: 0 0 5px 1px rgb(240, 240, 240);

    &-top {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;

      .slogan {
        margin-top: 15px;
        font-size: 25px;
        font-weight: 500;

        span {
          margin: 0 40px;
        }
      }

      :deep(.el-divider--horizontal) {
        margin: 15px;
        width: 90%;
      }
    }

    &-bottom {
      display: flex;

      .school {
        width: 120px;
        height: 120px;
        margin-right: 40px;

        img {
          width: 100%;
          height: 100%;
        }
      }

      .shop {
        min-width: 205px;
        padding-right: 20px;

        .logo {
          font-size: 30px;
          line-height: 50px;
          color: $theme-color;
        }
      }

      .ul-box {
        display: flex;
        margin-bottom: 15px;

        ul {
          margin: 0 40px;

          &:first-child {
            min-width: 64px;
          }

          &:last-child {
            min-width: 189px;
          }

          li {
            list-style: none;
            line-height: 35px;
          }
        }
      }

      .qr-code {
        display: flex;
        width: 250px;
        min-width: 250px;
        padding-left: 20px;
        justify-content: space-between;

        .title {
          margin: 0 auto;
        }
      }
    }
  }
}
</style>